/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */










function createLabel(Value){
    
    var  td = document.createElement('td');
    td.style.fontSize = '10pt';
    mxUtils.write(td, Value);
    return td;
    
}


function getDataValue(Class,num){
    
    var returnData=""
    var mydata= $("."+Class).val();
    if (mydata!=null){
        
    
        mydata=unescape(mydata);
        var Classv=mydata.split(";");
        var Classv2=Classv[1].split("__");
        
        returnData= Classv2[num];
    }
    return returnData;
}



function gatDataValuec(mydata,num){
    
    
    var returnData=""
  
    
    if (mydata!=null){
        mydata=unescape(mydata);
        var Classv=mydata.split(";");
        var Classv2=Classv[1].split("__");
        
        returnData= Classv2[num];
    }
    return returnData;
    
    
    
}


function addDatasetParameters(){
    
   
    var num=0;
    $(".serEventdata.modelDatal").each(function(){
        num++;
        var id="serEventdata";
        $("#"+id).parent().parent("tr").after('<tr class="' + id+ ' addprow morerow" style="display: table-row;"><td style="font-size: 10pt;">Value:</td><td style="font-size: 10pt;"><input class="'+id+'_event" style="width:100px;" value="'+ gatDataValuec($(this).val(),0)+'"></td><td style="font-size: 10pt;">Display Name:</td><td style="font-size: 10pt;"><input class="'+id+'_DisplayName" style="width:100px;" value="'+ gatDataValuec($(this).val(),1)+'" ></td></tr>');              
 
    })
     
    if (num>0)
    {
    
        $(".chadd_ser").attr("checked","checked");
        $(".serTable .addprow").show();
    }    
    
    num=0;
    $(".merEventdata.modelDatal").each(function(){
        num++;
      
        var id="merEventdata";
        $("#"+id).parent().parent("tr").after('<tr class="' + id+ ' addprow morerow" style="display: table-row;"><td style="font-size: 10pt;">Value:</td><td style="font-size: 10pt;"><input class="'+id+'_event" style="width:100px;" value="'+ gatDataValuec($(this).val(),0)+'"></td><td style="font-size: 10pt;">Display Name:</td><td style="font-size: 10pt;"><input class="'+id+'_DisplayName" style="width:100px;" value="'+ gatDataValuec($(this).val(),1)+'" ></td></tr>');              
 
 
    })
   
    if (num>0)
    {
    
        $(".chadd_mer").attr("checked","checked");
    
        $(".merTable .addprow").show();
    
    }    
  
}

function addmore(id){
      
    $("#"+id).parent().parent("tr").after('<tr class="' + id+ ' addprow morerow" style="display: table-row;"><td style="font-size: 10pt;">Value:</td><td style="font-size: 10pt;"><input class="'+id+'_event" style="width:100px;"></td><td style="font-size: 10pt;">Display Name:</td><td style="font-size: 10pt;"><input class="'+id+'_DisplayName" style="width:100px;"></td></tr>');              
 
  
}


function doOnLoad(){
        
    $(".addprow").hide();
        
    addDatasetParameters();
        
    

    $(".chadd").change(function(){
           
        var tbClass=   $(this).parent("td").parent("tr").parent().parent("table").attr("class");
           
        if ($(this).is(':checked')){
            
            
      
            $("." + tbClass + " .addprow").show()
        }else{
      
            $("." + tbClass + " .addprow").hide()
      
        }
      
           
           
    })
       
}








function modUpdateItemDialog(editorUi,mxUtils)
{
    
    var div = document.createElement('div');
    var divd1 = document.createElement('div');
    
    div.appendChild( createItem("System Properties" ,"" , "thtitle"));
    
    var table = document.createElement('table');
    table.style.width = '100%';
    table.style.height = '100%';
    var tbody = document.createElement('tbody');
  
    
    row = document.createElement('tr');
   
    row.appendChild(createLabel('Model Name:'));
    
    row.appendChild(createIntput(getValueData("Toph_model_data",1)[0],"modleName", 'width:100px;'));
    tbody.appendChild(row);
    
    row = document.createElement('tr');
   
    row.appendChild(createLabel('Description:'));
    
    
    row.appendChild(createIntput(getValueData("Toph_model_data",1)[1],"Description", 'width:100px;'));
    tbody.appendChild(row);
    
   
    table.appendChild(tbody);
    divd1.appendChild(table);
    
    
    
    
    div.appendChild(divd1);
    
    
    var myUp=mxUtils.button("Update", function(){
        
        $(".Toph_model_data").remove();
        
        
        
        var modleName= $(".modleName").val();
        var Description= $(".Description").val();   
        var value="modleName__Description;"+modleName+"__"+Description;
        var   myadddata=returnInputField ("Toph_model_data", value);
    
    
        $(".itmedata").append(myadddata);  
        
        editorUi.hideDialog();
      
    });
    myUp.setAttribute('class', 'myupdate');
      
            
    div.appendChild(myUp);
    this.container = div;
}





